import { createBrowserRouter, RouteObject } from 'react-router-dom'
import lazyComponents from './lazy'

// 含有菜单布局
const layoutPages: RouteObject[] = [
]

// 单独页面
const pages = [
  {
    path: '/dataAsset', // 资产目录
    element: <lazyComponents.DataAsset />,
    meta: {
      title: '数据资产目录'
    }
  },
  {
    path: '/counter', // 资产目录
    element: <lazyComponents.Counter />,
    meta: {
      title: '计算器页面 - 测试'
    }
  },
  {
    path: '/login',
    element: <lazyComponents.Login />,
    meta: {
      title: '用户登录'
    }
  },
  {
    path: '/404',
    element: <lazyComponents.Error404 />,
    meta: {
      title: '404页面'
    }
  }
]

export const routes: RouteObject[] = [
  {
    path: '',
    element: <lazyComponents.Layout />,
    children: [
      ...layoutPages,
      ...pages
    ]
  },
]

const router = createBrowserRouter(routes, {
  basename: import.meta.env.VITE_VISIT_CONTEXT_PATH // 设置目录结构
})

export default router